#include "HashTable.c"

void test_exists() {
    HashTable *states = create(kTableSize);
    assert(exists(states, "Texas") == false);

    KeyValue tx = {"Texas", "Austin"};
    add(states, &tx);
    printDebug(states);

    KeyValue tx2 = {"Texas", "Austin2"};
    add(states, &tx2);
//    assert(exists(states, "Texas") == true);
    printDebug(states);

    destroy(states);
}

void test_add_get() {
    HashTable * states = create(kTableSize);

    KeyValue la = {"Louisiana", "Baton Rouge"};
    add(states, &la);

    KeyValue me = {"Maine", "Augusta"};
    add(states, &me);

    KeyValue* capital1 = get(states, "Louisiana");
    assert(strcmp(capital1->value, "Baton Rouge") == 0);

    // add LA again, with new capital
    KeyValue la2 = {"Louisiana", "New Orleans"};
    add(states, &la2);

    // now capital should be Nawlins
    KeyValue* capital2 = get(states, "Louisiana");
    assert(strcmp(capital2->value, "New Orleans") == 0);

    destroy(states);
}

int main(void ) {
    test_add_get();
    return 0;
}
